<?php

namespace backend\models\course;
use yii\data\ActiveDataProvider;
use Yii;

/**
 * This is the model class for table "{{%edu_course_type}}".
 *
 * @property integer $type_id
 * @property string $type_name
 * @property integer $type_sort
 * @property integer $is_show
 * @property integer $type_addtime
 */
class CourseType extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%course_type}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['type_name'], 'required'],
            [['type_sort','is_show', 'type_addtime'], 'integer'],
			[ 'type_addtime','default', 'value' =>time(),],
            [['type_name'], 'string', 'max' => 10]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'type_id' => '分类ID',
            'type_name' => '分类名称',
            'type_sort' => '分类排序',
            'is_show' => '是否显示',
            'type_addtime' => '添加时间',
			'save' => '操作',
        ];
    }
	/**
	* 显示分类
	*/
	public function seltype()
    {
	
		return $this->find()
					->orderBy(['type_sort'=>SORT_DESC])
					->all();
	}
	/**
	* 前台显示分类
	*/
	public function Type()
    {
		return $this->find()
					->where(['is_show' => '1'])
					->orderBy(['type_sort'=>SORT_DESC])
					->all();
	}
}
